import ajax from '@/utils/request'
import { concatUrl } from '@/utils'

export function conversionCoupon(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/coupon/coupon-item/exchange', fields),
    data,
    method: 'POST'
  })
}

// 卡券列表
export function getCouponList(data, fields: string | object = { fields: 'canUsedAreaLabel,belongType,type,label,id,minPrice,baseAmount,name,carLicenseLimit,startAt,endAt,isUsed,typeLabel,discountType,belongStoreCode' }) {
  return ajax({
    url: concatUrl('/v2/coupon/coupon-item/index', fields),
    data
  })
}

// 卡券列表
export function getPlatformCouponList(data, fields: string | object = { fields: 'type,name,baseAmount,minPrice,startAt,endAt,status,sendType,couponIdCode,carLicenseLimit,shortDesc,id,isUsed,discountType,belongType,canUsedAreaLabel,belongStoreCode' }) {
  return ajax({
    url: concatUrl('/v2/coupon/coupon-item/index', fields),
    data
  })
}

// 卡券详情
export function getCouponDetails(data, fields: string | object = { fields: 'belongStoreCode,isCyCheckCoupon,command,isUsed,actualAmount,baseAmount,couponIdCode,disableReason,discountPrice,discountType,endAt,goodsCode,goodsId,id,isCouldSelected,minPriceLabel,mobile,name,startAt,status,type,typeLabel,vendorNameList,useDesc' }) {
  return ajax({
    url: concatUrl('/v1/coupon/coupon-item/view', fields),
    data
  })
}
// 分享（转增）卡券
export function sendCoupon(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/coupon/coupon-item/send-to-other', fields),
    data,
    method: 'POST'
  })
}
// 转增卡券状态
export function sendCouponDetails(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v1/coupon/coupon-item/send-to-other', fields),
    data,
    method: 'GET'
  })
}

//获取卡券二维码
export function getCouponQRCode(data, fields: string | object = { fields: 'qrcode' }) {
  return ajax({
    url: concatUrl('/v2/coupon/coupon-item/get-qrcode', fields),
    data
  })
}

//核销卡券
export function writeOffCoupon(data, fields: string | object = { fields: '*' }) {
  return ajax({
    url: concatUrl('/v2/coupon/coupon-item/write-off', fields),
    data,
    method: 'POST'
  })
}

// 获取年审券核销记录
export function getCouponWriteOffList(data, fields: string | object = { fields: 'id,baseAmount,mobileHidden,name,usedAt,storeName' }) {
  return ajax({
    url: concatUrl('/v2/coupon/coupon-item/get-write-off-list', fields),
    data
  })
}
